package com.kmxd.ams.core.ocr;

import cn.hutool.core.util.ObjectUtil;
import com.kmxd.ams.core.common.enums.OcrDeployTypeEnum;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.List;

/**
 * ocr配置信息
 *
 * @author nickbi
 */
@Slf4j
@Data
@Configuration
@ConfigurationProperties(prefix = OcrProperties.PREFIX)
public class OcrProperties {

  /** 配置前缀 */
  public static final String PREFIX = "ocr";

  /** ocr线程数量 */
  private Integer threadNum;
  /** ocr文件目录分层数量 */
  private Integer dirNum;
  /** ocr服务地址,多个服务使用;分隔 */
  private String url;
  /** 检测模型 */
  private String det;
  /** 识别模型 */
  private String rec;
  /** 分类模型 */
  private String cls;
  /** 是否将ocr内容写到数据库 */
  private boolean writeToDb = false;

  private String ocrFileApi = "/ocr/file";
  private String ocrPathApi = "/ocr/path";

  private OcrDeployTypeEnum deployTypeEnum;
  private List<String> urlList;

  public void setUrl(String url) {
    this.url = url;
    String[] split = url.split(";");
    this.urlList = ObjectUtil.isEmpty(split) ? Lists.newArrayList() : Arrays.asList(split);
  }

  /**
   * 获取服务url
   *
   * @return
   */

}
